package com.yanlin.servicemap.service;

import com.yanlin.internalcommon.dto.ResponseResult;
import com.yanlin.internalcommon.response.DicDirectionResponse;
import com.yanlin.servicemap.client.MapDirectionClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>标题：DrivingService</p>
 * <p>功能：</p>
 * <p>
 * 其他说明：
 * </p>
 * <p>审核：</p>
 * <p>重构：</p>
 * <p>创建日期：2025-06-09 17:20</p>
 *
 * @author yanlin
 */
@Service
@Slf4j
public class DirectionService {

    @Autowired
    private MapDirectionClient mapDirectionClient;
    /**
     * 根据起点和终点经纬度，计算距离是时长
     * @param depLongitude
     * @param depLatitude
     * @param destLongitude
     * @param destLatitude
     * @return
     */
    public ResponseResult driving(String depLongitude, String depLatitude, String destLongitude, String destLatitude) {
        log.info("service-map: 出发地经度={}, 出发地纬度={}, 目的地经度={}, 目的地纬度={}", depLongitude, depLatitude, destLongitude, destLatitude);
        // 获取距离和时间
        ResponseResult direction = mapDirectionClient.direction(depLongitude, depLatitude, destLongitude, destLatitude);

        log.info("距离和时间：{}", direction.getData().toString());
        DicDirectionResponse dicDirectionResponse = new DicDirectionResponse();
        dicDirectionResponse.setDistance(132);
        dicDirectionResponse.setDuration(10);

        return ResponseResult.success(direction.getData());
    }
}